var mask = null;
var id = null;
var xzauditstatus = null;
var bz = null;
$(function() { // 初始化内容
	mui.init();
	mask = mui.createMask(); //遮罩层
	login_user = JSON.parse(localStorage.getItem('loginUser'));
	id = sessionStorage.getItem('siteUseFeeId')
	datetime_init();

	setTimeout(function() {
		loadSiteUseFeeRecord();
	}, 300);

})



function loadSiteUseFeeRecord() {

	var data = {};
	data['id'] = 
	console.log("场地费记录id====" + JSON.stringify(data));
	jQuery.ajax({
		type: "post",
		headers: {
			'Authorization': login_user.token
		},
		url: serverip + "fxgw/loadSiteFeeJf",
		contentType: 'application/json;charset=UTF-8',
		data: JSON.stringify(data),
		dataType: "json",
		timeout: 10000,
		beforeSend: function() {

			mask.show(); //显示遮罩层
		},
		success: function(res) {
			mask.close(); //显示遮罩层
			console.log("场地费记录====" + JSON.stringify(res));

			loadForm(res.skList[0]);

			var xzauditstatus = res.skList[0].xzauditstatus;

			if (xzauditstatus != "审核中") {
				jQuery("#submit").css("display", "none");
			}

		},
		error: function(e) {

			mask.close(); //显示遮罩层
			var msg = e.responseJSON.message;
			var code = e.responseJSON.status;
			mui.alert('错误编码' + code + "\n" + "错误信息:" + msg);
			console.log("错误信息====" + JSON.stringify(e));

		}
	});

}



function pass() {
	xzauditstatus = "校长审核通过";
	saveAuditResult()
}

function noPass() {
	xzauditstatus = "校长审核不通过";
	noPassText();
}

function saveAuditResult() {
	var data = {};
	data['ids'] = id;
	if (bz != null) {
		data['bz'] = bz
		data['auditposition'] = "校长"
	}
	data['xzauditstatus'] = xzauditstatus;
	console.log("审核成交记录上传====" + JSON.stringify(data));
	jQuery.ajax({
		type: "post",
		headers: {
			'Authorization': login_user.token
		},
		url: serverip + "fxxz/cdfXzAudit",
		contentType: "application/json;charset=UTF-8",
		data: JSON.stringify(data),
		dataType: "json",
		timeout: 10000,
		beforeSend: function() {

			mask.show(); //显示遮罩层	   
		},
		success: function(data) {

			mask.close(); //显示遮罩层  	    	
			console.log(JSON.stringify(data));
			mui.alert('审批完成');
			setTimeout(function() {
				mui.back();
			}, 1000);

		},

		error: function(e) {

			mask.close(); //显示遮罩层
			mui.alert('系统错误');
			console.log("审核错误" + JSON.stringify(data));
		}
	});
}



function noPassText() {
	var btnArray = ['取消', '确定'];
	mui.prompt('请填写不通过原因', '请填写不通过原因', new Array('取消', '确定'), function(e) {
		if (e.index == 1) {
			//mui.toast(e.value);	    
			bz = e.value;
			saveAuditResult();

		} else {
			mui.toast('您取消了输入');
		}
	});
}
